<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Web Service Documentation &mdash; pyTunesConnect v1.0.1 documentation</title>
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
          URL_ROOT:    '',
          VERSION:     '1.0.1',
          COLLAPSE_MODINDEX: false,
          FILE_SUFFIX: ''
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/interface.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="contents" title="Global table of contents" href="contents.html" />
    <link rel="index" title="Global index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="top" title="pyTunesConnect v1.0.1 documentation" href="index.html" />
    <link rel="next" title="Code Documentation" href="code.html" />
    <link rel="prev" title="Setup and Installation Instructions" href="setup.html" />
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li class="right" >
          <a href="code.html" title="Code Documentation"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="setup.html" title="Setup and Installation Instructions"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">pyTunesConnect v1.0.1 documentation</a> &raquo;</li>
      </ul>
    </div>
    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  
  <div class="section" id="web-service-documentation">
<h1 id="web-service-documentation">Web Service Documentation<a class="headerlink" href="#web-service-documentation" title="Permalink to this headline">¶</a></h1>
<p>pytunesconnect.py has a built in web service that can be easily used via something like CURL to insert the charts generated into other web pages.  You must ensure that the device making the request to the web service is listed in the allowed ips setting as it also controls access to this web service.</p>
<p>Currently the web service only supports pulling charts for new and repeat downloads, more may be added in later versions.</p>
<div class="section" id="downloads-chart">
<h2 id="downloads-chart">Downloads Chart<a class="headerlink" href="#downloads-chart" title="Permalink to this headline">¶</a></h2>
<p>This web service call will return HTML necessary to place an interactive javascript chart of downloads based on the appleid that is passed into the system.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>Common Issues:</p>
<ul class="last simple">
<li>The new download charts are interactive dygraphs (<a class="reference external" href="http://danvk.org/dygraphs/">http://danvk.org/dygraphs/</a>). Dygraphs are not happy when placed inside a &lt;center&gt;  tag. This applies to the CSS text-align  property as well. If you want to center a Dygraph, put it inside a table with align = center set.</li>
<li>The dygraphs library relies heavily on HTML&#8217;s &lt;canvas&gt; tag, which Microsoft Internet Explorer does not support. Fortunately, some clever engineers created the excanvas library, which implements the &lt;canvas&gt; tag in IE using VML. You can add IE support to any page using dygraphs by including the following in your page: &lt;head&gt; &lt;!&#8211;[if IE]&gt;&lt;script src=&#8221;excanvas.js&#8221;&gt;&lt;/script&gt;&lt;![endif]&#8211;&gt;&lt;/head&gt;</li>
</ul>
</div>
<p>Any page showing one of these charts should include the following in the &lt;head&gt; tag of the page:</p>
<pre>&lt;script type="text/javascript" src="http://danvk.org/dygraphs/dygraph-combined.js"&gt;&lt;/script&gt;</pre>
<div class="section" id="variables">
<h3 id="variables">Variables<a class="headerlink" href="#variables" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>action - REQUIRED - Use &#8220;dlchartapi&#8221; for download charts</li>
<li>app - REQUIRED - Apple id of the application the chart is being requested for</li>
<li>width - OPTIONAL - Width of the chart code generated in pixels (defaults to 640)</li>
<li>height - OPTIONAL - Height of the chart code generated in pixels (defaults to 480)</li>
<li>type - OPTIONAL - Acceptable values are &#8220;new&#8221; or &#8220;reinstalls&#8221; (defaults to &#8220;new&#8221;)</li>
<li>divname - OPTIONAL - Charts are displayed with a div tag, if more than one chart appears on a page they need unique names (defaults to &#8220;chart&#8221;)</li>
<li>offfset - OPTIONAL - Integer to indicate the number of days of history to generate in the chart, for example 7 would give you the last week. Passing 0 will return a chart containing all history data (defaults to &#8220;0&#8221;)</li>
</ul>
</div>
<div class="section" id="sample-call">
<h3 id="sample-call">Sample Call<a class="headerlink" href="#sample-call" title="Permalink to this headline">¶</a></h3>
<p>A sample call:</p>
<pre>pytunesconnect.py?action=dlchartapi&amp;app=359232243&amp;type=new&amp;width=200&amp;height=400&amp;divname=chart2&amp;offset=31</pre>
</div>
<div class="section" id="sample-response">
<h3 id="sample-response">Sample Response<a class="headerlink" href="#sample-response" title="Permalink to this headline">¶</a></h3>
<p>Sample response:</p>
<pre>&lt;div id="chart2" style="width:400px; height:200px;"&gt;&lt;/div&gt;&lt;script type="text/javascript"&gt;  g2 = new Dygraph(document.getElementById("chart2"),
    "Date,NewDownloads\n" +
    "20100309,46\n" +
    "20100308,47\n" +
    "20100307,74\n" +
    "20100306,166\n" +
    "20100305,278\n" +
    "20100304,109\n" +
    "20100303,29\n" +
    "20100302,15\n"
    );&lt;/script&gt;</pre>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3>Table Of Contents</h3>
            <ul>
<li><a class="reference external" href="">Web Service Documentation</a><ul>
<li><a class="reference external" href="#downloads-chart">Downloads Chart</a><ul>
<li><a class="reference external" href="#variables">Variables</a></li>
<li><a class="reference external" href="#sample-call">Sample Call</a></li>
<li><a class="reference external" href="#sample-response">Sample Response</a></li>
</ul>
</li>
</ul>
</li>
</ul>

            <h4>Previous topic</h4>
            <p class="topless"><a href="setup.html" title="previous chapter">Setup and Installation Instructions</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="code.html" title="next chapter">Code Documentation</a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="_sources/webservice.txt">Show Source</a></li>
            </ul>
            <h3>Quick search</h3>
            <form class="search" action="search.html" method="get">
              <input type="text" name="q" size="18" /> <input type="submit" value="Go" />
              <input type="hidden" name="check_keywords" value="yes" />
              <input type="hidden" name="area" value="default" />
            </form>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li class="right" >
          <a href="code.html" title="Code Documentation"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="setup.html" title="Setup and Installation Instructions"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">pyTunesConnect v1.0.1 documentation</a> &raquo;</li>
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright 2010, Jonathan Carroll.
      Last updated on May 06, 2010.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
    </div>
  </body>
</html>